home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 13 - 1997 (partial) / 13.03 Mar 97 / Leigh.OberonF / MactechRot13.source (.txt) < prev   
Encoding:
Oberon Document  |  1996-09-29  |  2.4 KB  |  65 lines  |  [BINA/hDmp]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. (* This Module is a sample using the Oberon/F framework.  It performs a ROT-13 on the current text selection. This module can be added to any program that uses the text subsystem.  PROCEDURE Do is a parameterless procedure called a "command" .  This is a complete module and can be compiled by iteself.  *)
  17. MODULE MactechRot13;
  18.       IMPORT Models, TextModels, TextControllers, Domains;
  19.      PROCEDURE Do*;
  20.          VAR     tc: TextControllers.Controller; 
  21.                             beg, end: LONGINT;
  22.                             tr: TextModels.Reader; 
  23.                             ch: CHAR;
  24.                             buf: TextModels.Model; 
  25.                             tw: TextModels.Writer;          
  26.                             script: Domains.Operation;
  27.         BEGIN
  28.             tc := TextControllers.Focus();
  29.             IF (tc # NIL) & tc.HasSelection() THEN
  30.                 tc.GetSelection(beg, end);
  31.                 buf := TextModels.Clone(tc.text); 
  32.                 tw :=buf.NewWriter(NIL);
  33.                 tr := tc.text.NewReader(NIL); 
  34.                 tr.SetPos(beg);
  35.                 tr.ReadChar(ch);
  36.                 WHILE (tr.Pos() <= end) & ~tr.eot DO
  37.                     IF ((ch >= "a") & (ch <= "m"))  OR
  38.                          ((ch >= "A") & (ch <= "M")) THEN 
  39.                             ch := CHR(ORD(ch)+13);
  40.                             ELSIF ((ch >= "n") & (ch <= "z")) OR 
  41.                                     ((ch >= "N") & (ch <= "Z")) THEN 
  42.                                     ch := CHR(ORD(ch)-13)
  43.                                 END;
  44.                     tw.WriteChar(ch);
  45.                     tr.ReadChar(ch)
  46.                     END;
  47.                 Models.BeginScript(tc.text, "Rot13", script);
  48.                 tc.text.Delete(beg, end); 
  49.                 tc.text.CopyFrom(beg, buf, 0, end - beg);
  50.                 Models.EndScript(tc.text, script)
  51.                 END
  52.         END Do;
  53. END MactechRot13.
  54. TextControllers.StdCtrlDesc
  55. TextControllers.ControllerDesc
  56. Containers.ControllerDesc
  57. Controllers.ControllerDesc
  58. TextRulers.StdRulerDesc
  59. TextRulers.RulerDesc
  60. TextRulers.StdStyleDesc
  61. TextRulers.StyleDesc
  62. TextRulers.AttributesDesc
  63. Helvetica
  64. Documents.ControllerDesc
  65.